package com.github.ghsea.scheduler.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.Serializable;
import java.util.Date;

/**
 * @author guhai
 * @since 2021/6/17 20:35
 */
public class Task implements Serializable {

    private String bizCode;

    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    private Date stopTime;

    private int intervalSeconds;

    public String getBizCode() {
        return bizCode;
    }

    public Task setBizCode(String bizCode) {
        this.bizCode = bizCode;
        return this;
    }

    public Date getStopTime() {
        return stopTime;
    }

    public Task setStopTime(Date stopTime) {
        this.stopTime = stopTime;
        return this;
    }

    public int getIntervalSeconds() {
        return intervalSeconds;
    }

    public Task setIntervalSeconds(int intervalSeconds) {
        this.intervalSeconds = intervalSeconds;
        return this;
    }

    @Override
    public String toString() {
        return "Task{" +
                "bizCode='" + bizCode + '\'' +
                ", stopTime=" + stopTime +
                ", intervalSeconds=" + intervalSeconds +
                '}';
    }

    public static void main(String[] args) throws JsonProcessingException {
        Task t=new Task();
        t.setBizCode("12345");
        t.setIntervalSeconds(30);
        t.setStopTime(new Date());

        ObjectMapper mapper = new ObjectMapper();
        System.out.println(mapper.writeValueAsString(t));
    }
}
